<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <input type="text" id="username">
    <input type="text" id="passworld">
    <script>

        var username = document.getElementById("username");

        username.oninput = function (e) {
            console.log(e.target.value);

        }

        username.onselect=function(){
            console.log("选中了")
        }
    
        //失去焦点和回去的时候触发
        var passworld=document.getElementById("passworld");
        passworld.onchange=function(e){
          console.log(e.target.value)
        }
    </script>
</body>

</html>